﻿
@{
    ViewBag.Title = "list";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>视频源管理</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link rel="shortcut icon" href="/skin/H4.2/favicon.ico">
    <link href="/skin/H4.2/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/skin/H4.2/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- jqgrid-->
    <link href="/skin/H4.2/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
    <link href="/skin/H4.2/css/animate.css" rel="stylesheet">
    <link href="/skin/H4.2/css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        /* Additional style to fix warning dialog position */

        #alertmod_table_list_2 {
            top: 900px !important;
        }

        #pager_list_1_left {
            display: none;
        }
    </style>
</head>
<body class="gray-bg ">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    @*<div class="ibox-title">
                            <h5>jQuery Grid Plugin – jqGrid</h5>
                        </div>*@
                    <div class="ibox-content">
                        <form role="form" class="form-inline" id="form1" name="form1">
                            <div class="form-group">
                                <label for="exampleInputEmail2" class="sr-only">关键字</label>
                                <input type="email" placeholder="请输入关键字" id="keyword" name="keyword" class="form-control">
                            </div>
                            <button class="btn btn-primary" type="button" onclick="add()">添加</button>
                            <button class="btn btn-white" type="button" id="btnsearch">查询</button>
                        </form>
                    </div>
                    <div class="ibox-content">
                        <div class="jqGrid_wrapper">
                            <table id="table_list_1"></table>
                            <div id="pager_list_1"></div>
                        </div>
                        <p>&nbsp;</p>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="/skin/H4.2/js/jquery.min.js?v=2.1.4"></script>
    <script src="/skin/H4.2/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- Peity -->
    <script src="/skin/H4.2/js/plugins/peity/jquery.peity.min.js"></script>
    <!-- jqGrid -->
    <script src="/skin/H4.2/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
    <script src="/skin/H4.2/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
    <!-- 自定义js -->
    <script src="/skin/H4.2/js/content.js?v=1.0.0"></script>
    <!-- Page-Level Scripts -->
    <script>
        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };

        $(document).ready(function () {

            $("#btnsearch").click(function () {
                $("#table_list_1").jqGrid('setGridParam', {
                    postData: $('#form1').serializeObject(),
                    page: 1
                }).trigger("reloadGrid"); //重新载入
            });
            var jsonuserinfo = $('#form1').serializeObject();

            $.jgrid.defaults.styleUI = 'Bootstrap';
            $("#table_list_1").jqGrid({
                url: '/Hhome/splist',
                //data: mydata,
                datatype: "json",
                mtype: 'POST',
                height: '500',
                autowidth: true,
                shrinkToFit: true,
                multiselect: true,
                multiboxonly: true,
                postData:$('#form1').serializeObject(),
                cellEdit: true,
                rowNum: 15,
                rowList: [10, 20, 30],
                colNames: ['编号', '所属分类', '视频名称', '视频地址','操作'],
                colModel: [
                    {
                        name: 'id',
                        index: 'id',
                        width: 60,
                        sorttype: "int"
                    },
                    {
                        name: 'patrolType',
                        index: 'patrolType',
                        width: 120,
                    },
                    {
                        name: 'remark',
                        index: ',',
                        width: 200
                    },
                    {
                        name: 'address',
                        index: ',',
                        width: 500
                    },
                     {
                         label: '编辑', name: 'id', index: 'id', width: 100, align: 'center',
                         formatter: function (cellvalue, options, rowObject) {
                             return "<a data-toggle='modal' href='splistadd?id=" + cellvalue + "' data-target='#mmXgmodal'>编辑</a> | <a href='javascript:splistdelete(" + cellvalue + ")'>删除</a> ";

                         },
                     },
                ],
                pager: "#pager_list_1",
                viewrecords: true,
                // caption: "jqGrid 示例1",
                hidegrid: false
            });
            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_1').setGridWidth(width);
                $('#table_list_2').setGridWidth(width);
            });
        });

        function add()
        {
            $("#mmXgmodal").modal({
                remote: "splistadd"
            });
        }

        function save()
        {

            $.ajax({
                type: "POST",
                url: "splistadd",
                data: $("#addform").serialize(),
                success: function (msg) {
                    $("#mmXgmodal").on("hidden.bs.modal", function () {
                        $(this).removeData("bs.modal");
                    });
                    $("#mmXgmodal").modal('hide');
                    $("#btnsearch").click();
                }
            });

        }
        function splistdelete(_id) {

            $.ajax({
                type: "POST",
                url: "splistdelete",
                data: "id=" + _id,
                success: function (msg) {
                    if (msg == "true") {
                        $("#btnsearch").click();
                    }
                    else {
                        alert(msg);
                    }
                }
            });

        }

    </script>

    <div class="modal fade" id="mmXgmodal" tabindex="-1" role="dialog" aria-labelledby="modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content  animated bounceInRight">

            </div>
        </div>
    </div>
</body>
</html>
